<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>第一种头部</title>
    <link rel="stylesheet" type="text/css" href="../../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui.css" />
    <style>
        html,
        body {
            width: 100%;
            min-height: 100%;
            background: #f7f7f7;
            line-height: 1;
        }
        /*搜索框*/

        .search_box {
            background-color: #fff;
            padding: 0.2rem 0.75rem;
            padding-top: calc(25px + 0.3rem);
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .search {
            flex: 1;
            background-color: #f3efee;
            display: flex;
            align-items: center;
            padding: 0.4rem 0.2rem;
            margin-right: 0.2rem;
        }

        .search img {
            width: 1rem;
            margin-right: 0.2rem;
        }

        .search input {
            line-height: 1rem;
            height: 1rem;
        }

        .cancel_btn {
            font-size: 0.8rem;
            color: #333;
        }
        /*搜索提示*/

        .tips_box {
            margin-top: 3rem;
        }

        .tip_title {
            text-align: center;
            margin-bottom: 1rem;
            font-size: 0.7rem;
            color: #999;
            font-weight: 600;
        }

        .other_tip div {
            text-align: center;
            color: #f23030;
            font-size: 0.8rem;
            margin-bottom: 0.8rem;
        }

        .other_tip div.active {
            border-left: 1px solid #999;
            border-right: 1px solid #999;
            box-sizing: border-box;
        }
        /*结果集*/

        .result_box {
            background: #fff;
            margin-top: 0.5rem;
        }

        .sort_list {
            padding: 0.45rem 0;
            background-color: #fff;
            display: flex;
            align-items: center;
            position: relative;
        }

        .sort_list::after {
            content: "";
            height: 1px;
            width: calc(100% - 0.75rem);
            position: absolute;
            background: #edeae8;
            bottom: 0;
            left: 0.75rem;
        }

        .sort_list .num_logo {
            width: 1.5rem;
            margin: 0rem 0.75rem;
        }

        .sort_list .num_name {
            font-size: 0.8rem;
            color: #333;
        }
    </style>
</head>

<body>
    <div class="app">
        <div class="search_box">
            <div class="search">
                <img src="../../../image/four/search.png" alt="">
                <input type="text" name="" v-model="keywords" placeholder="请输入好友昵称" value="">
            </div>
            <div class="cancel_btn" onclick="close_win()">取消</div>
        </div>



        <div class="tips_box">
            <div class="tip_title">指定搜索内容</div>
            <div class="other_tip">
                <div class="aui-col-xs-4">个人动态</div>
                <div class="aui-col-xs-4 active">个性标签</div>
                <div class="aui-col-xs-4">好友昵称</div>
                <div class="aui-col-xs-4">文章</div>
                <div class="aui-col-xs-4 active">表情</div>
                <div class="aui-col-xs-4">音乐</div>
            </div>
        </div>

        <div class="result_box">
            <div v-for="friend_info in data" class="sort_list" @click="open_new_win('two','详细资料','好友','../../../image/four/delete_friend.png',friend_info.user_id)">
                <div class="num_logo">
                    <div :style="'background:url('+friend_info.head_img+') center/cover no-repeat;width:1.5rem;height:1.5rem;'"></div>
                </div>
                <div v-if="friend_info.username" class="num_name">{{friend_info.username}}</div>
                <div v-else class="num_name">该用户很懒，没有填写名字</div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../../script/api.js"></script>
<script type="text/javascript" src="../../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../../script/vue.min.js"></script>
<script type="text/javascript" src="../../../script/utils.js"></script>
<script type="text/javascript" src="../../../script/common.js"></script>
<script type="text/javascript" src="../../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../../script/aui-pull-refresh.js"></script>
<script type="text/javascript">
    apiready = function() {



    };

    // 实例化vue  实现搜索功能
    var search_vue = new Vue({
        el: ".app",
        data: {
            keywords: '',
            data: []
        },
        created: function() {
            console.log('创建');
        },
        mounted: function() {
            console.log("绑定");
        },
        watch: {
            keywords: function() {
                var $this = this;
                $this.search_fn();
            }
        },
        methods: {
            //搜索
            search_fn: function(keywords) {
                // api.showProgress({
                //     style: 'default',
                //     animationType: 'fade',
                //     title: '努力加载中...',
                //     text: '先喝杯茶...',
                //     modal: false
                // });
                var $this = this;
                if ($this.keywords != "") {
                    api.ajax({
                        url: window.Url.Community_searchFriendList,
                        method: 'post',
                        data: {
                            values: {
                                token: $api.getStorage('token'),
                                keywords: $this.keywords
                            }
                        }
                    }, function(ret, err) {
                        // api.hideProgress();
                        if (ret) {
                            console.log(JSON.stringify(ret));
                            if (ret.re == 1) {
                                $this.data = ret.data.list;
                                $(".tips_box").hide();
                            } else {
                                $this.data = [];
                                $(".tips_box").show();
                            }

                        } else {

                            alert(JSON.stringify(err));
                        }
                    });
                } else {
                    $this.data = [];
                    $(".tips_box").show();
                }

            },
            // 打开对应页面的头部
            open_new_win: function(index, title, type, img_src, friend_id) {
                api.openWin({
                    name: 'four_' + index + "_header",
                    url: 'four_' + index + '_header.html',
                    pageParam: {
                        title: title,
                        type: type,
                        img_src: img_src,
                        friend_id: friend_id
                    }
                });
            }
        }
    })


    // 关闭当前窗口
    function close_win() {
        api.closeWin({});
    }
</script>

</html>
